package com.zyl.pts.config.exception;

import com.zyl.pts.config.enums.ResultCode;
import lombok.Getter;

/**
 * @version v1.0
 * @ProjectName: SpringBootWeb
 * @Package: com.zyl.demo.exception
 * @ClassName: ServiceException
 * @Description TODO(自定义业务逻辑异常，用于抛出由用户操作不当导致的异常)
 * @Author 翟玉龙
 * @Date 2024/11/15-14:26
 */
@Getter
public class ServiceException extends RuntimeException {

    private final int code;

    public ServiceException(String message) {
        super(message);
        this.code = 500;
    }

    public ServiceException(int code, String message) {
        super(message);
        this.code = code;
    }

    public ServiceException(ResultCode resultCode) {
        super(resultCode.getMessage());
        this.code = resultCode.getCode();
    }
}
